// -*- coding: utf-8 -*- 
/**
 * Project: Java8InActionT
 * Creator: yanking
 * Create time: 2022-02-22 23:51
 * IDE: IntelliJ IDEA
 * Introduction:
 */
package com.ThreadPool.customThreadPool;

public class myTask implements Runnable {
    private int id; // 每一个任务都有自己独特的id

    public myTask(int id) {
        this.id = id;
    }

    //  自定义目标类
    @Override
    public void run() {
        String name = Thread.currentThread().getName();
        System.out.println("Now running thread is " + name);
        try {
            Thread.sleep(200);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("Thread" + name + "has finished " + id + "task!");
    }

    @Override
    public String toString() {
        return "myTask{" +
                "id=" + id +
                '}';
    }
}
